@extends("layout.app")

@section("content")

    <div class="form-inline">

        <div class="form-group has-success">
            <input class="form-control" id="begin_time" placeholder="开始时间"/>
        </div>
        <div class="form-group has-success">
            <input class="form-control" id="end_time" placeholder="结束时间"/>
        </div>
        <div class="form-group has-success">
            &nbsp;<button id="button" class="btn btn-default" onclick="jQuery('#rowed3').setGridParam({postData: postData()}).trigger('reloadGrid')"><i class="fa fa-search"></i> 查询</button>
        </div>
        <div class="form-group has-success">
            &nbsp;<button id="button" class="btn btn-success" onclick="setDate('<?php echo date("Y-m-d", strtotime("Monday this week"))?>', '')"> 本周</button>
        </div>
        <div class="form-group has-success">
            &nbsp;<button id="button" class="btn btn-info" onclick="setDate('<?php echo date("Y-m-d", strtotime("Monday this week")-604800)?>', '<?php echo date("Y-m-d", strtotime("last Sunday"))?>')"> 上周</button>
        </div>
        <div class="form-group has-success">
            &nbsp;<button id="button" class="btn btn-warning" onclick="setDate('<?php echo date("Y-m-01")?>', '')"> 本月</button>
        </div>
        <div class="form-group has-success">
            &nbsp;<button id="button" class="btn btn-danger" onclick="setDate('<?php echo date("Y-m-01",  strtotime(date("Y-m-01") . " -1 month"))?>', '<?php echo date("Y-m-d",  strtotime(date("Y-m-01") . " -1 day"))?>')"> 上月</button>
        </div>
    </div>
    <div class="separator"></div>
    <div class="box-body">

        <table id="rowed3"></table>
        <div id="prowed3"></div>

    </div>
    <script>

        $(document).ready(function() {

            var data = {
                url :"/agent/zongdai/detail",
                postData: postData(),
                colNames: ["ID", "时间", "交易前", "交易后", "交易金额", "说明"],
                colModel: [
                    {
                        name  : "id",
                        key   : true,
                        hidden: true
                    },{
                        name: "create_time",
                        formatter:'date',
                        formatoptions: {srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s'},
                        searchoptions: {
                            sopt: ['lt', 'le', 'gt', 'ge'],
                            dataInit : function (elem) {
                                $(elem).datepicker({
                                    dateFormat: 'yy-mm-dd',
                                    monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
                                    dayNamesMin: ['日','一','二','三','四','五','六'] });
                            }
                        }
                    },{
                        name: "before",
                        search :false,
                        formatter: function(cellvalue) {
                            return cellvalue/100;
                        }
                    }, {
                        name: "after",
                        search :false,
                        formatter: function(cellvalue) {
                            return cellvalue/100;
                        }
                    }, {
                        name: "money",
                        search :false,
                        formatter: function(cellvalue) {
                            return cellvalue/100;
                        }
                    }, {
                        name: "detail",
                        sortable: false
                    }],
                caption: '<i class="fa fa-list"></i> 账户明细',
                sortname: "id",
                sortorder: "desc",
                autowidth: false
            };

            jqGrid(data, false, false, false);

            $(".form-inline .form-control").datepicker({
                dateFormat: 'yy-mm-dd',
                monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
                dayNamesMin: ['日','一','二','三','四','五','六'] });

        });

        function setDate(begin_time, end_time) {

            $("#begin_time").val(begin_time);
            $("#end_time").val(end_time);

            jQuery('#rowed3').setGridParam({postData: postData()}).trigger('reloadGrid')
        }

        function postData() {

            return {
            	zongdai: '<?php echo $request->get("zongdai")?>',
                begin_time: $("#begin_time").val(),
                end_time: $("#end_time").val()
            }
        }

    </script>


@endsection